home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2007 December
/
PCWKCD1207B.iso
/
Blogowanie poza sfera
/
Flock 0.9.1.3 stable
/
flock-0.9.1.3.en-US.win32.exe
/
flock
/
yahootoolbar.xpi
/
components
/
nsYahooHashtable.js
< prev
next >
Wrap
Text File
|
2007-01-12
|
4KB
|
140 lines
/*
* Copyright 2005 - 2006 Yahoo! Inc. All rights reserved.
*/
function nsIYahooHashtable(){
this.values = {};
this.keys = [];
this.add = function(key, value){
if(this.values == null){
this.keys = new Array();
this.values = new Array();
}
this.values[key] = value;
this.keys[this.keys.length] = key;
}
this.addString = function(key, value){
if(this.values == null){
this.keys = new Array();
this.values = new Array();
}
this.values[key] = value;
this.keys[this.keys.length] = key;
}
this.clear = function(){
if(this.values != null){
for(var i = 0; i < this.values.length; i++){
if(this.values[i] instanceof Components.interfaces.nsIYahooFeedNode){
this.values[i].destroy();
}
this.values[i] = null;
this.keys[i] = null;
}
}
this.keys = null;
this.values = null;
}
this.get = function(key){
if(this.values != null && typeof(this.values[key]) != 'undefined'){
return this.values[key];
}
return null;
}
this.getString = function(key){
if(this.values != null && typeof(this.values[key]) == "string"){
return this.values[key];
}
return null;
}
this.getKeys = function(count){
count.value = 0;
if(this.keys != null){
count.value = this.keys.length;
return this.keys;
}
else{
return [];
}
}
this.getValues = function(count){
var out = new Array();
var i = 0
if(this.values != null){
for(props in this.values){
i++
out[out.length] = this.values[props];
}
}
count.value = i;
return out;
}
this.getStringValues = function(count){
var out = new Array();
count.value = 0
if(this.values != null){
for(props in this.values){
if(typeof(this.values[props]) == "string"){
count.value++
out[out.length] = this.values[props];
}
}
}
return out;
}
this.size = function(){
return ((this.values != null) ? this.values.length : 0);
}
this.toString = function(){
var out = "";
if(this.values != null){
for(prop in this.values){
if(out != ""){
out += "&";
}
out += prop +" = "+ this.values[prop];
}
}
return out;
}
this.debug = function(msg){
if(typeof(Components.interfaces.nsIDebugLoggerManager) != 'undefined'){
logMngr = Components.classes["@mozmonkey.com/debuglogger/manager;1"].getService(Components.interfaces.nsIDebugLoggerManager);
logger = logMngr.registerLogger("yfeedtest");
logger.log(3, msg);
}
}
}
nsIYahooHashtable.prototype = {
QueryInterface: function (iid) {
if(!iid.equals(Components.interfaces.nsIYahooHashtable) && !iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
};
function NSGetModule(compMgr, fileSpec) {
return {
myCID : Components.ID("{5398bfe0-de19-444a-b59d-edff8f10b93d}"),
myProgID : "@yahoo.com/feed/hashtable;1",
firstTime : true,
registerSelf : function (compMgr, fileSpec, location, type) {
if (this.firstTime) {
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(this.myCID, "Yahoo! Hashtable", this.myProgID, fileSpec, location, type);
},
getClassObject : function (compMgr, cid, iid) {
if (!cid.equals(this.myCID)) throw Components.results.NS_ERROR_NO_INTERFACE;
if (!iid.equals(Components.interfaces.nsIFactory)) throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
return this.myFactory;
},
myFactory : {
createInstance : function (outer, iid) {
if (outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
return (new nsIYahooHashtable()).QueryInterface(iid);
}
},
canUnload : function(compMgr) { return true; }
};
}